<?php


abstract class BaseThirdparties extends BaseObject  implements Persistent {


  const PEER = 'ThirdpartiesPeer';

	
	protected static $peer;

	
	protected $id;

	
	protected $cif;

	
	protected $name;

	
	protected $address;

	
	protected $contactcomm;

	
	protected $contactfact;

	
	protected $payrule;

	
	protected $faxnumber;

	
	protected $phonenumber;

	
	protected $mobilenumber;

	
	protected $email;

	
	protected $webpage;

	
	protected $notes;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function __construct()
	{
		parent::__construct();
		$this->applyDefaultValues();
	}

	
	public function applyDefaultValues()
	{
	}

	
	public function getId()
	{
		return $this->id;
	}

	
	public function getCif()
	{
		return $this->cif;
	}

	
	public function getName()
	{
		return $this->name;
	}

	
	public function getAddress()
	{
		return $this->address;
	}

	
	public function getContactcomm()
	{
		return $this->contactcomm;
	}

	
	public function getContactfact()
	{
		return $this->contactfact;
	}

	
	public function getPayrule()
	{
		return $this->payrule;
	}

	
	public function getFaxnumber()
	{
		return $this->faxnumber;
	}

	
	public function getPhonenumber()
	{
		return $this->phonenumber;
	}

	
	public function getMobilenumber()
	{
		return $this->mobilenumber;
	}

	
	public function getEmail()
	{
		return $this->email;
	}

	
	public function getWebpage()
	{
		return $this->webpage;
	}

	
	public function getNotes()
	{
		return $this->notes;
	}

	
	public function setId($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = ThirdpartiesPeer::ID;
		}

		return $this;
	} 
	
	public function setCif($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->cif !== $v) {
			$this->cif = $v;
			$this->modifiedColumns[] = ThirdpartiesPeer::CIF;
		}

		return $this;
	} 
	
	public function setName($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->name !== $v) {
			$this->name = $v;
			$this->modifiedColumns[] = ThirdpartiesPeer::NAME;
		}

		return $this;
	} 
	
	public function setAddress($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->address !== $v) {
			$this->address = $v;
			$this->modifiedColumns[] = ThirdpartiesPeer::ADDRESS;
		}

		return $this;
	} 
	
	public function setContactcomm($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->contactcomm !== $v) {
			$this->contactcomm = $v;
			$this->modifiedColumns[] = ThirdpartiesPeer::CONTACTCOMM;
		}

		return $this;
	} 
	
	public function setContactfact($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->contactfact !== $v) {
			$this->contactfact = $v;
			$this->modifiedColumns[] = ThirdpartiesPeer::CONTACTFACT;
		}

		return $this;
	} 
	
	public function setPayrule($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->payrule !== $v) {
			$this->payrule = $v;
			$this->modifiedColumns[] = ThirdpartiesPeer::PAYRULE;
		}

		return $this;
	} 
	
	public function setFaxnumber($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->faxnumber !== $v) {
			$this->faxnumber = $v;
			$this->modifiedColumns[] = ThirdpartiesPeer::FAXNUMBER;
		}

		return $this;
	} 
	
	public function setPhonenumber($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->phonenumber !== $v) {
			$this->phonenumber = $v;
			$this->modifiedColumns[] = ThirdpartiesPeer::PHONENUMBER;
		}

		return $this;
	} 
	
	public function setMobilenumber($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->mobilenumber !== $v) {
			$this->mobilenumber = $v;
			$this->modifiedColumns[] = ThirdpartiesPeer::MOBILENUMBER;
		}

		return $this;
	} 
	
	public function setEmail($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->email !== $v) {
			$this->email = $v;
			$this->modifiedColumns[] = ThirdpartiesPeer::EMAIL;
		}

		return $this;
	} 
	
	public function setWebpage($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->webpage !== $v) {
			$this->webpage = $v;
			$this->modifiedColumns[] = ThirdpartiesPeer::WEBPAGE;
		}

		return $this;
	} 
	
	public function setNotes($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->notes !== $v) {
			$this->notes = $v;
			$this->modifiedColumns[] = ThirdpartiesPeer::NOTES;
		}

		return $this;
	} 
	
	public function hasOnlyDefaultValues()
	{
						if (array_diff($this->modifiedColumns, array())) {
				return false;
			}

				return true;
	} 
	
	public function hydrate($row, $startcol = 0, $rehydrate = false)
	{
		try {

			$this->id = ($row[$startcol + 0] !== null) ? (string) $row[$startcol + 0] : null;
			$this->cif = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
			$this->name = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
			$this->address = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
			$this->contactcomm = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
			$this->contactfact = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
			$this->payrule = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
			$this->faxnumber = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
			$this->phonenumber = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
			$this->mobilenumber = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
			$this->email = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null;
			$this->webpage = ($row[$startcol + 11] !== null) ? (string) $row[$startcol + 11] : null;
			$this->notes = ($row[$startcol + 12] !== null) ? (string) $row[$startcol + 12] : null;
			$this->resetModified();

			$this->setNew(false);

			if ($rehydrate) {
				$this->ensureConsistency();
			}

						return $startcol + 13; 
		} catch (Exception $e) {
			throw new PropelException("Error populating Thirdparties object", $e);
		}
	}

	
	public function ensureConsistency()
	{

	} 
	
	public function reload($deep = false, PropelPDO $con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("Cannot reload a deleted object.");
		}

		if ($this->isNew()) {
			throw new PropelException("Cannot reload an unsaved object.");
		}

		if ($con === null) {
			$con = Propel::getConnection(ThirdpartiesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
		}

				
		$stmt = ThirdpartiesPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
		$row = $stmt->fetch(PDO::FETCH_NUM);
		$stmt->closeCursor();
		if (!$row) {
			throw new PropelException('Cannot find matching row in the database to reload object values.');
		}
		$this->hydrate($row, 0, true); 
		if ($deep) {  
		} 	}

	
	public function delete(PropelPDO $con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(ThirdpartiesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}
		
		$con->beginTransaction();
		try {
			ThirdpartiesPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollBack();
			throw $e;
		}
	}

	
	public function save(PropelPDO $con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(ThirdpartiesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}
		
		$con->beginTransaction();
		try {
			$affectedRows = $this->doSave($con);
			$con->commit();
			ThirdpartiesPeer::addInstanceToPool($this);
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollBack();
			throw $e;
		}
	}

	
	protected function doSave(PropelPDO $con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = ThirdpartiesPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setNew(false);
				} else {
					$affectedRows += ThirdpartiesPeer::doUpdate($this, $con);
				}

				$this->resetModified(); 			}

			$this->alreadyInSave = false;

		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = ThirdpartiesPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = ThirdpartiesPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		$field = $this->getByPosition($pos);
		return $field;
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getId();
				break;
			case 1:
				return $this->getCif();
				break;
			case 2:
				return $this->getName();
				break;
			case 3:
				return $this->getAddress();
				break;
			case 4:
				return $this->getContactcomm();
				break;
			case 5:
				return $this->getContactfact();
				break;
			case 6:
				return $this->getPayrule();
				break;
			case 7:
				return $this->getFaxnumber();
				break;
			case 8:
				return $this->getPhonenumber();
				break;
			case 9:
				return $this->getMobilenumber();
				break;
			case 10:
				return $this->getEmail();
				break;
			case 11:
				return $this->getWebpage();
				break;
			case 12:
				return $this->getNotes();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true)
	{
		$keys = ThirdpartiesPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getCif(),
			$keys[2] => $this->getName(),
			$keys[3] => $this->getAddress(),
			$keys[4] => $this->getContactcomm(),
			$keys[5] => $this->getContactfact(),
			$keys[6] => $this->getPayrule(),
			$keys[7] => $this->getFaxnumber(),
			$keys[8] => $this->getPhonenumber(),
			$keys[9] => $this->getMobilenumber(),
			$keys[10] => $this->getEmail(),
			$keys[11] => $this->getWebpage(),
			$keys[12] => $this->getNotes(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = ThirdpartiesPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setId($value);
				break;
			case 1:
				$this->setCif($value);
				break;
			case 2:
				$this->setName($value);
				break;
			case 3:
				$this->setAddress($value);
				break;
			case 4:
				$this->setContactcomm($value);
				break;
			case 5:
				$this->setContactfact($value);
				break;
			case 6:
				$this->setPayrule($value);
				break;
			case 7:
				$this->setFaxnumber($value);
				break;
			case 8:
				$this->setPhonenumber($value);
				break;
			case 9:
				$this->setMobilenumber($value);
				break;
			case 10:
				$this->setEmail($value);
				break;
			case 11:
				$this->setWebpage($value);
				break;
			case 12:
				$this->setNotes($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = ThirdpartiesPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setCif($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setName($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setAddress($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setContactcomm($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setContactfact($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setPayrule($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setFaxnumber($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setPhonenumber($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setMobilenumber($arr[$keys[9]]);
		if (array_key_exists($keys[10], $arr)) $this->setEmail($arr[$keys[10]]);
		if (array_key_exists($keys[11], $arr)) $this->setWebpage($arr[$keys[11]]);
		if (array_key_exists($keys[12], $arr)) $this->setNotes($arr[$keys[12]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(ThirdpartiesPeer::DATABASE_NAME);

		if ($this->isColumnModified(ThirdpartiesPeer::ID)) $criteria->add(ThirdpartiesPeer::ID, $this->id);
		if ($this->isColumnModified(ThirdpartiesPeer::CIF)) $criteria->add(ThirdpartiesPeer::CIF, $this->cif);
		if ($this->isColumnModified(ThirdpartiesPeer::NAME)) $criteria->add(ThirdpartiesPeer::NAME, $this->name);
		if ($this->isColumnModified(ThirdpartiesPeer::ADDRESS)) $criteria->add(ThirdpartiesPeer::ADDRESS, $this->address);
		if ($this->isColumnModified(ThirdpartiesPeer::CONTACTCOMM)) $criteria->add(ThirdpartiesPeer::CONTACTCOMM, $this->contactcomm);
		if ($this->isColumnModified(ThirdpartiesPeer::CONTACTFACT)) $criteria->add(ThirdpartiesPeer::CONTACTFACT, $this->contactfact);
		if ($this->isColumnModified(ThirdpartiesPeer::PAYRULE)) $criteria->add(ThirdpartiesPeer::PAYRULE, $this->payrule);
		if ($this->isColumnModified(ThirdpartiesPeer::FAXNUMBER)) $criteria->add(ThirdpartiesPeer::FAXNUMBER, $this->faxnumber);
		if ($this->isColumnModified(ThirdpartiesPeer::PHONENUMBER)) $criteria->add(ThirdpartiesPeer::PHONENUMBER, $this->phonenumber);
		if ($this->isColumnModified(ThirdpartiesPeer::MOBILENUMBER)) $criteria->add(ThirdpartiesPeer::MOBILENUMBER, $this->mobilenumber);
		if ($this->isColumnModified(ThirdpartiesPeer::EMAIL)) $criteria->add(ThirdpartiesPeer::EMAIL, $this->email);
		if ($this->isColumnModified(ThirdpartiesPeer::WEBPAGE)) $criteria->add(ThirdpartiesPeer::WEBPAGE, $this->webpage);
		if ($this->isColumnModified(ThirdpartiesPeer::NOTES)) $criteria->add(ThirdpartiesPeer::NOTES, $this->notes);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(ThirdpartiesPeer::DATABASE_NAME);

		$criteria->add(ThirdpartiesPeer::ID, $this->id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setId($this->id);

		$copyObj->setCif($this->cif);

		$copyObj->setName($this->name);

		$copyObj->setAddress($this->address);

		$copyObj->setContactcomm($this->contactcomm);

		$copyObj->setContactfact($this->contactfact);

		$copyObj->setPayrule($this->payrule);

		$copyObj->setFaxnumber($this->faxnumber);

		$copyObj->setPhonenumber($this->phonenumber);

		$copyObj->setMobilenumber($this->mobilenumber);

		$copyObj->setEmail($this->email);

		$copyObj->setWebpage($this->webpage);

		$copyObj->setNotes($this->notes);


		$copyObj->setNew(true);

	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new ThirdpartiesPeer();
		}
		return self::$peer;
	}

	
	public function clearAllReferences($deep = false)
	{
		if ($deep) {
		} 
	}

} 